# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-gen
_pkgname=gen
pkgver=1.0
pkgrel=0
pkgdesc="Simple, efficient iterators for OCaml"
url="https://github.com/c-cube/gen/"
arch="all !riscv64"  # limited by ocaml aport
license="BSD-2-Clause"
depends="ocaml-runtime"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="dune dune-configurator ocaml"
checkdepends="ocaml-ounit-dev ocaml-qcheck-dev ocaml-qtest-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/c-cube/gen/archive/v$pkgver.tar.gz
	dont-use-external-seq.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
fb4ec2ab35a1aba0dcc8439b11f14a0a785d939f661f505aec88a6f2ca6ca87e14ddfda860d9c180b215190b76690de87040c144582f069224f7e58d37ef48a0  ocaml-gen-1.0.tar.gz
d9e4bc65357c4f83e39418a14e299e7626229545fac4c5e38e172f5dcb1e47abf651af77bc7ccdcc6ccaf15a2d9856c166f62b8a3882a781865ea5aacd4ed0de  dont-use-external-seq.patch
"
